<template>
  <!-- 零星采购计划变更 详情 -->
  <div class="e-form">
    <div class="tabs" v-if="Object.keys(basicFormData).length != 0">
      <el-tabs tab-position="left" v-model="tabsName" @tab-click="onChangeTab">
        <!-- 基本信息 -->
        <el-tab-pane
          label="基本信息"
          name="baseInfo"
          :disabled="clickTabFlag"
        ></el-tab-pane>
        <el-tab-pane
          label="物资明细"
          name="goodsAndMaterials"
          :disabled="clickTabFlag"
        ></el-tab-pane>

        <el-tab-pane
          label="附件信息"
          name="accessory"
          :disabled="clickTabFlag"
        ></el-tab-pane>
        <el-tab-pane
          label="审核历史"
          name="auditHistory"
          :disabled="clickTabFlag"
        ></el-tab-pane>

        <div>
          <!-- 基本信息 -->
          <div id="baseInfoCon" class="con">
            <div class="e-form">
                <BillTop title="零星采购计划变更详情" @cancel="cancel"></BillTop>
              <div class="tabs">
                <div class="tabs-title" id="baseInfo">基本信息</div>
                <div style="width: 100%" class="form">
                  <el-form :model="basicFormData" label-width="150px">
                    <el-row>
                      <el-col :span="12">
                        <el-form-item label="变更编号">
                          {{ basicFormData.billNo }}
                        </el-form-item>
                      </el-col>
                      <el-col :span="12">
                        <el-form-item label="单据机构">
                          {{ basicFormData.orgName }}
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <el-row>
                      <el-col :span="12">
                        <el-form-item label="计划年度">

                          {{basicFormData.year}}

                        </el-form-item>
                      </el-col>
                      <el-col :span="12">
                        <el-form-item label="计划月份">
                         {{basicFormData.month}}

                        </el-form-item>
                      </el-col>
                    </el-row>
                    <el-row>
                      <el-col :span="12">
                        <el-form-item label="要签合同">
                          {{ basicFormData.isSignContract === true ? '是' : '否'  }}
                        </el-form-item>
                      </el-col>
                      <el-col :span="12">
                        <el-form-item label="变更日期">
                          {{basicFormData.planDate}}

                        </el-form-item>

                      </el-col>
                    </el-row>
                    <el-row>
                      <el-col :span="12">
                        <el-form-item label="不含税计划金额(元)">
                          {{basicFormData.amountChanged}}

                        </el-form-item>

                      </el-col>
                      <el-col :span="12">
                        <el-form-item label="原计划金额(元)">
                          <el-col :span="12">
                            {{basicFormData.totalAmount}}

                          </el-col>
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <el-row>
                      <el-col :span="12">
                        <el-form-item label="税额">
                          {{basicFormData.taxAmountChanged}}

                        </el-form-item>
                      </el-col>
                      <el-col :span="12">
                        <el-form-item label="税率%">
                          {{basicFormData.taxRateChanged + '%'}}

                        </el-form-item>

                      </el-col>
                    </el-row>
                    <el-row>
                      <el-col :span="12">
                        <el-form-item label="变更后计划金额(元)">
                          {{basicFormData.totalAmountChanged}}

                        </el-form-item>
                      </el-col>
                      <el-col :span="12">
                        <el-form-item label="填报人">
                          {{ basicFormData.preparer }}
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <el-row>
                      <el-col :span="12">
                        <el-form-item label="币种">
                          {{basicFormData.currency}}

                        </el-form-item>
                      </el-col>
                      <el-col :span="12">
                        <el-form-item label="状态">
                          {{['草稿','审核中','已审核','已关闭','','已作废'][basicFormData.state]}}
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <el-row>
                      <el-form-item label="变更期数">
                        {{ basicFormData.period }}
                      </el-form-item>
                    </el-row>
                    <el-row>
                      <el-form-item label="备注">
                        {{basicFormData.remarks}}

                      </el-form-item>
                    </el-row>

                    <el-row>
                      <el-col :span="12">
                        <el-form-item label="本位币">
                          {{ basicFormData.baseCurName }}
                        </el-form-item>
                      </el-col>
                      <el-col :span="12">
                        <el-form-item label="本位币汇率">
                          {{ basicFormData.baseCurRate }}
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <!-- <el-row>
                      <el-form-item label="计划金额（本位币）">
                        {{ basicFormData.baseCurTotalAmount }}
                      </el-form-item>
                    </el-row> -->
                   <el-row v-if="basicFormData.state === '5' ">
                              <el-form-item label="作废人：" >
                                {{
                                    basicFormData.nullifyCreator
                                }}
                            </el-form-item>
                      </el-row>
                    <el-row v-if="basicFormData.state === '5' ">
                        <el-col :span="12">
                            <el-form-item label="作废原因：">
                                {{
                                    basicFormData.nullifyReason
                                }}
                            </el-form-item>
                          </el-col>
                            <el-col :span="12">
                              <el-form-item label="作废说明：">
                                {{
                                    basicFormData.nullifyDescription
                                }}
                            </el-form-item>
                          </el-col>
                      </el-row>

                  </el-form>
                </div>
              </div>
            </div>

            <!-- ------------------------------------------------------------------------------------- -->
          </div>

           <!-- 物资明细 -->
          <div id="goodsAndMaterialsCon" class="con">
            <div class="tabs-title" id="goodsAndMaterials">物资明细</div>
            <div class="e-table">

              <el-table
              class="table"
                :data="goodsAndMaterialsList"
                border
                style="width: 100%"
                :cell-class-name="cellClsNm"
                :row-class-name="tableRowClass"
                :header-cell-style="{ textAlign: 'center' }"
                :cell-style="{ textAlign: 'center' }"
                :tree-props="{
                  children: 'children',
                  hasChildren: 'hasChildren',
                }"
                row-key="uuid"
                :max-height="$store.state.tableHeight"
                 ref="table"
                v-sortTable="{ 'tableData': goodsAndMaterialsList, '_this': this, 'ref': 'table' }"
              >

                <el-table-column
                  prop="materialClassName"
                  label="类别"
                  min-width="200"
                  align="left"
                >

                </el-table-column>
                <el-table-column
                  prop="materialName"
                  label="物资名称"
                  width="100"
                >
                </el-table-column>
                <el-table-column prop="spec" label="规格型号" width="100">
                </el-table-column>
                <el-table-column prop="unit" label="计量单位" width="100">
                </el-table-column>
                <el-table-column prop="texture" label="材质" width="100">
                </el-table-column>
                <el-table-column
                  prop="quantity"
                  label="数量"
                  width="200"
                >

                </el-table-column>

                <el-table-column
                  prop="price"
                  label="单价（元）"
                  width="130"
                >

                </el-table-column>
                <el-table-column
                  prop="amount"
                  label="金额（元）"
                  width="130"
                >
                  <!-- 系统默认计算，即计划数量*市场单价，不可编辑，金额累计保留2位小数，采用四舍五入方式。-->
                </el-table-column>

                <el-table-column
                  prop="purchaseType"
                  label="采购方式"
                  width="100"
                   v-if="basicFormData.isSignContract"
                >
                  <!-- 要签合同，才显示，录入人可选择，审核中由审核人核准数据为准，单选。 -->
                  <template slot-scope="{ row }">
                      <span>{{
                      ["邀请招标", "公开招标","询价","竞争性谈判","单一性来源","甲控（业主招标）"][row.purchaseType]
                      }}</span>
                  </template>
                </el-table-column>
                <el-table-column prop="quantityChanged" width="100">
                     <template slot="header">
                        <div class="tab-header">数量<span class="tab-heade-icon">变</span></div>
                    </template>
                </el-table-column>
                <el-table-column prop="priceChanged" width="100">
                     <template slot="header">
                        <div class="tab-header">单价<span class="tab-heade-icon">变</span></div>
                    </template>
                </el-table-column>
                 <el-table-column prop="amountChanged" width="100">
                     <template slot="header">
                        <div class="tab-header">金额（元）<span class="tab-heade-icon">变</span></div>
                    </template>
                </el-table-column>
                  <el-table-column
                  prop="purchaseTypeChanged"
                  width="150"
                   v-if="basicFormData.isSignContract"
                >
                    <template slot="header">
                   <div class="tab-header">采购方式<span class="tab-heade-icon">变</span></div>
                   </template>
                    <template slot-scope="{ row }">
                      <span>{{
                      ["邀请招标", "公开招标","询价","竞争性谈判","单一性来源","甲控（业主招标）"][row.purchaseTypeChanged]
                      }}</span>
                  </template>
                </el-table-column>
              </el-table>
            </div>
          </div>

            <!-- 附件信息 -->
                <div id="accessoryCon" class="con">
                    <div class="tabs-title" id="accessory">附件信息</div>
                    <attach-comp :relationId="attachId" bucketName="material" isView v-if="objFlag.flag5"/>
                    <div class="seize-a-seat" v-else>
                        <i class="el-icon-loading"></i>
                    </div>
                </div>
         <!-- 审核历史 -->
         <div id="auditHistoryCon" class="con">
              <div class="tabs-title" id="auditHistory">审核历史</div>
              <div class="e-table">
                  <ComAuditHistoryIndex
                      :tableData.sync="auditHistoryTable"
                      @getAuditHistory="getAuditHistory"
                      ref="AuditHistoryRef"
                  />
              </div>
          </div>
        </div>
      </el-tabs>
    </div>
    <div id="seat" :style="{ height: seatHeight + 'px' }"></div>
    <div class="buttons">
        <el-button type="primary" size="small" style="background: #2e61d7"
       v-if="basicFormData.state === '1' || basicFormData.state === '2'"
        v-debounce
         @click="Print"
        >打印</el-button
      >
         <ComExaButtons
                v-if="basicFormData.state != 5"
                :auditState="auditState"
                :state="basicFormData.state"
                 :founderId="founderId"
                @exas="exas"
            />

        <!-- <el-button type="primary" size="small" style="background: #2e61d7"
       v-if="basicFormData.state === '1'"    v-debounce
       @click="audit"
        >审核</el-button
      >
       <el-button type="primary" size="small" style="background: #2e61d7"
      @click="undoAudit"
      v-if="basicFormData.state === '1'"
      v-debounce
        >撤回</el-button
      >
      <el-button type="primary" size="small" style="background: #2e61d7"
        @click="nullify()"
        v-debounce
        v-if="basicFormData.state === '1'"
        >作废</el-button
      > -->
      <el-button size="small" @click="cancel">关闭</el-button>
    </div>
  </div>
</template>

<script>
import '@/utils/jquery.scrollTo.min'
import { mapMutations,  } from 'vuex'
import {  getUuid } from '@/utils/common'
import AttachComp from '@/components/common/attachIndex'
import { openAppClient } from '@/utils/common'
import request from '@/api/materials/plan.js'
import ComAuditHistoryIndex from '@/pages/materialsmanagement/components/auditHistory/auditHistoryIndex'
import { webprintReport } from '@/utils/common'
import {  showLoading, hideLoading } from '@/utils/common'
export default {
    data () {
        return {
            tabsName: 'baseInfo',
            userName: '',
            form: {
                name: '',
                region: '',
                date1: '',
                date2: '',
                delivery: false,
                type: [],
                resource: '',
                desc: '',
            },
            tableData: [],
            goodsAndMaterialsList: [], //明细
            auditHistoryTable: [], //审核历史
            auditState: {}, //按钮状态
            founderId: '',
            value: '',
            textarea: '',
            formData: {},
            screenWidth: 0,
            screenHeight: 0,
            lastConHeight: 0,
            clickTabFlag: false, // 如果手动点击时，则不做滚动事件逻辑，只有滚动屏幕时才走滚动事件逻辑
            //基本信息表单数据
            basicFormData: {
                'amount': null,
                'amountChanged': null,
                'baseCurAmount': null,
                'baseCurAmountChanged': null,
                'baseCurId': '',
                'baseCurName': '',
                'baseCurRate': null,
                'baseCurTaxAmount': null,
                'baseCurTaxAmountChanged': null,
                'baseCurTotalAmount': null,
                'baseCurTotalAmountChanged': null,
                'billId': '',
                'billNo': '',
                'currency': '',
                'currencyId': '',
                'founderId': '',
                'founderName': '',
                'gmtCreate': '',
                'gmtModified': '',
                'isSignContract': false,
                'month': null,
                'nullifyCreated': '',
                'nullifyCreator': '',
                'nullifyCreatorId': '',
                'nullifyDescription': '',
                'nullifyReason': '',
                'orgId': '',
                'orgName': '',
                'period': null,
                'planDate': '',
                'preparer': '',
                'preparerId': '',
                'remarks': '',
                'rmbAmount': null,
                'rmbAmountChanged': null,
                'rmbId': '',
                'rmbName': '',
                'rmbRate': null,
                'rmbTaxAmount': null,
                'rmbTaxAmountChanged': null,
                'rmbTotalAmount': null,
                'rmbTotalAmountChanged': null,
                'sporadicPurchasePlanBillId': '',
                'sporadicPurchasePlanBillNo': '',
                'state': '',
                'taxAmount': null,
                'taxAmountChanged': null,
                'taxRate': null,
                'taxRateChanged': null,
                'totalAmount': null,
                'totalAmountChanged': null,
                'workId': '',
                'year': null
            },
            objFlag: {
                flag5: false,
            },
            billid: '',
            orgId: '', //机构id
            orgName: '', //机构名称
            auditParams: {  //审核
                'billId': this.$route.query.billid,
                'billType': 10051,
                'freeNextUnitIndex': null,
                'freeNextUser': '',
                'isPass': true,
                'isShareInAudit': true,
                'opinion': '',
                'orgId': '',
                'orgName': '',
                'userId': '',
                'workId': ''
            },
            nullifyParams: { //作废
                'billId': this.$route.query.billid,
                'billType': 10051,
                'nullifyCreated': '',
                'nullifyCreator': '',
                'nullifyCreatorId': '',
                'nullifyDescription': '',
                'nullifyReason': ''
            },
        }
    },
    computed: {
        judgeRoute () {
            if (this.$route.path.includes('Add')) {
                return false
            }
            return true
        },
        // 填补底部空白，以使高度够滚动
        seatHeight () {
            return this.screenHeight - 72 - this.lastConHeight
        },
        attachId () {
            return this.billId
        }
    },
    components: {
        AttachComp,
        ComAuditHistoryIndex,
    },
    created () {
        let data = JSON.parse(localStorage.getItem('vuex'))
        this.orgId = data.userInfo.orgInfo.orgId
        this.orgName = data.userInfo.orgInfo.orgName
        this.billid = this.$route.query.billid
        this.founderId = localStorage.getItem('userId')
        this.getBasicData() //进入页面就获取基本信息数据
        this.getAttach()
        this.getMasterPlan()
        this.getCurrentUnitInfo()
    },
    mounted () {
    // 获取最后一个内容区域的高度，计算底部空白
        this.getLastConHeight()

        // 保存所有tabName
        const arr = ['baseInfo', 'goodsAndMaterials', 'accessory', 'auditHistory']
        let $idsTop = []
        window.addEventListener('scroll', () => {
            // 如果手动点击时，则不做滚动事件逻辑，只有滚动屏幕时才走滚动事件逻辑
            if (this.clickTabFlag) {
                return
            }

            if (!$idsTop[$idsTop.length - 1]) {
                $idsTop = arr.map(item => {
                    const $item = document.getElementById(item)
                    let itemTop = null
                    if ($item) {
                        itemTop = $item.offsetTop
                    }
                    return itemTop
                })
            }
            const scrollTop =
        document.documentElement.scrollTop || document.body.scrollTop
            // 倒序查找
            let curLocal = 0
            for (let len = $idsTop.length, i = len - 1; i >= 0; i--) {
                let item = $idsTop[i]
                if (scrollTop + 1 >= item) {
                    curLocal = i
                    break
                }
            }
            // 设置对应tabName
            this.tabsName = arr[curLocal]
        })

        this.screenWidth = document.documentElement.clientWidth - this.topHeight
        this.screenHeight = document.documentElement.clientHeight - this.topHeight
        window.addEventListener('resize', () => {
            this.screenWidth = document.documentElement.clientWidth - this.topHeight
            this.screenHeight = document.documentElement.clientHeight - this.topHeight
            $idsTop = arr.map(item => {
                const itemTop = document.getElementById(item).offsetTop
                return itemTop
            })
        })
    },
    methods: {
        ...mapMutations(['setSelectedInfo', 'setAuditParams']),

        ...mapMutations(['setAuditParam']),
        // 获取按钮状态
        getCurrentUnitInfo () {
            request
                .getCurrentUnitInfo({
                    billId: this.$route.query.billid,
                    billType: 10051,
                    freeNextUnitIndex: 0,
                    freeNextUser: '',
                    isPass: true,
                    isShareInAudit: true,
                    opinion: ''
                })
                .then(res => {
                    this.auditState = res
                })
        },
        // 按钮组件触发事件
        exas (data) {
            switch (data) {
            case 'audit':
                this.audit() //审核
                break
            case 'undoAudit':
                this.undoAudit() //撤回
                break
            case 'submitCommit':
                this.submit() //提交
                break
            case 'submit':
                this.save() //保存
                break
            case 'nullify':
                this.nullify() //作废
                break
            case 'deleteData':
                this.ctDelete() //删除
                break
            default:
                break
            }
        },
        //打印
        async  Print () {
            const  printData =  ()=>{
                showLoading()
                try{
                    const  params =  {
                        'reportTitle': '零星采购计划单', //报表名
                        'orgName': '', //单据机构
                        'reportQRUri': '', //报表内容URI
                        'billNo': '', //单据编码
                        'summaryInfoItems': [ //基本信息
                        ],
                        'tables': [ //表格
                        ]
                    }
                    const basicFormData = this.basicFormData
                    params.orgName = basicFormData.orgName
                    params.reportQRUri = window.location.href
                    params.billNo = basicFormData.billNo
                    //基本信息
                    const baseInfo = [
                        ['机构名称', basicFormData.orgName, true],
                        ['变更编号', basicFormData.billNo, false],
                        ['计划日期', basicFormData.planDate, false],
                        ['计划年度', basicFormData.year, false],
                        ['计划月份', basicFormData.month, false],
                        ['计划金额', basicFormData.totalAmount, false],
                        ['备注', basicFormData.remarks, false],
                        ['附件： 张', '', false],
                    ]
                    baseInfo.forEach(item=>{
                        const summaryInfoItem = {}
                        summaryInfoItem.label = item[0]
                        summaryInfoItem.value = item[1]
                        summaryInfoItem.isFullRow = item[2]
                        params.summaryInfoItems.push(summaryInfoItem)
                    })
                    //总计划明细
                    const arr = []
                    this.goodsAndMaterialsList.forEach(item=>{
                        item.children.forEach(x=>{
                            x.topClassName = item.topClassName
                            if(x.purchaseTypeChanged == 0) {
                                x.purchaseTypeChangeds = '邀请招标'
                            }else if(x.purchaseTypeChanged == 1) {
                                x.purchaseTypeChangeds = '公开招标'
                            }else if(x.purchaseTypeChanged == 2) {
                                x.purchaseTypeChangeds = '询价'
                            }else if(x.purchaseTypeChanged == 3) {
                                x.purchaseTypeChangeds = '竞争性谈判'
                            }else if(x.purchaseTypeChanged == 4) {
                                x.purchaseTypeChangeds = '单一性来源'
                            }else if(x.purchaseTypeChanged == 4) {
                                x.purchaseTypeChangeds = '甲控（业主招标）'
                            }
                            arr.push(x)
                        })
                    })
                    if(basicFormData.isSignContract == true) {
                        const goodsTable = {
                            'tableTitle': '零星采购计划明细',
                            'tableContent': {
                                '物资类别': 'topClassName',
                                '物资名称': 'materialName',
                                '规格': 'spec',
                                '材质': 'texture',
                                '单位': 'unit',
                                '数量': 'quantityChanged',
                                '单价': 'priceChanged',
                                '金额': 'amountChanged',
                                '采购方式': 'purchaseTypeChangeds',
                            },
                            'tableData': arr, //表格数据
                        }
                        params.tables.push(goodsTable)
                    }else{
                        const goodsTable = {
                            'tableTitle': '零星采购计划明细',
                            'tableContent': {
                                '物资类别': 'topClassName',
                                '物资名称': 'materialName',
                                '规格': 'spec',
                                '材质': 'texture',
                                '单位': 'unit',
                                '数量': 'quantityChanged',
                                '单价': 'priceChanged',
                                '金额': 'amountChanged',
                            },
                            'tableData': arr, //表格数据
                        }
                        params.tables.push(goodsTable)
                    }
                    //审核历史
                    const auditData = {
                        'tableTitle': '审核历史',
                        'tableContent': {
                            '审核级次': 'unitName',
                            '审核人': 'assignUser',
                            '审核人岗位': 'userTitle',
                            '审核时间': 'completeTime',
                            '审核意见': 'opinion',

                        },
                        'tableData': this.auditHistoryTable, //表格数据
                    }
                    params.tables.push(auditData)
                    hideLoading()
                    return params

                }catch(err) {
                    console.log(err)
                    this.clientPop('err', '打印失败')
                    hideLoading()
                }

            }

            const data = await printData()
            webprintReport(data)
        },

        //明细数据汇总方法
        uniqueArray (arr, key) {
            const map = new Map()
            return arr.filter(item => {
                const val = item[key] + '' || getUuid()
                return !map.has(val) && map.set(val, 1)
            })
        },

        ...mapMutations(['setPopConfirm']),
        //查询附件信息
        getAttach () {
            this.objFlag.flag5 = true
        },

        //获取基本信息数据
        getBasicData () {
            this.$Ajax
                .httpGet({
                    url: '/material/sporadicPurchasePlanChanged/findById',
                    params: {
                        id: this.billid,
                    },
                })
                .then(res => {
                    console.log('基本信息', res)
                    this.basicFormData = res
                    this.basicFormData.totalAmount = this.basicFormData.totalAmount.toFixed(2)
                    this.basicFormData.taxAmountChanged = this.basicFormData.taxAmountChanged.toFixed(2)
                    this.basicFormData.amountChanged = this.basicFormData.amountChanged.toFixed(2)
                    this.basicFormData.totalAmountChanged = this.basicFormData.totalAmountChanged.toFixed(2)
                })
        },
        //获取明细数据
        getMasterPlan () {
            this.$Ajax
                .httpGet({
                    url: '/material/sporadicPurchasePlanChanged/getListById',
                    params: {
                        id: this.billid,
                    },
                })
                .then(res => {
                    res.forEach(item => {
                        item.materialClassName = item.topClassName
                        item.uuid = getUuid()
                        item.children.forEach(i => {
                            i.uuid = i.dtlId
                            i.amountChanged = i.amountChanged.toFixed(2)
                        })
                        const count = item.children.reduce(
                            (prev, c) => (prev += Number(c.amountChanged) || 0),
                            0
                        )
                        item.materialName = `小计： ${count}`
                    })
                    this.goodsAndMaterialsList = res
                })
        },
        //撤回
        undoAudit () {
            this.clientPop('info', '确定要返回上一步操作吗?', this.undoAuditData)
        },
        undoAuditData () {
            const params2 = {
                billId: this.billid, //单据Id  ***
                billType: '10051', //单据编码  ***
                dtls: [], //审核中字段值变更历史
                freeNextUnitIndex: 0, //下一步审核步骤
                freeNextUser: '', //下一步审核人ID
                isPass: true, //审核是否通过
                isShareInAudit: true, //是否共享审核节点
                opinion: '', //审核意见   ***
                orgId: '', //单据机构Id
                orgName: '', //单据机构名称
                userId: this.userId, //审核人Id    ***
                workId: '', //流程Id
            }
            request.undoAudit(params2).then(() => {
                this.clientPop('suc', '撤回成功！', this.cancel, null, this.cancel)
            })
        },

        //作废
        nullify () {
            this.setAuditParams(this.nullifyParams)
            openAppClient('/nullifyDialog', '单据作废原因', () => {
                const auditParams = JSON.parse(localStorage.vuex).auditParams
                request.nullify(auditParams).then(() => {
                    this.clientPop('suc', '作废成功', this.cancel)
                })
            })
        },

        //审核
        audit () {
            this.setAuditParams(this.auditParams)
            // 客户端弹窗弹出本地页面
            openAppClient('/exaDialog', '填写审核意见', () => {
                const auditParams = JSON.parse(localStorage.vuex).auditParams
                request.audit(auditParams).then(() => {
                    this.clientPop('suc', '审核成功', this.cancel)
                })
            }, null, null, null, 'small')
        },
        //获取历史审核列表
        getAuditHistory () {
            const params = {
                billId: this.billid,
                billType: '10051',
                freeNextUnitIndex: 0,
                freeNextUser: '',
                isPass: true,
                isShareInAudit: true,
                opinion: '',
                orgId: '',
                orgName: '',
                userId: '',
                workId: ''
            }
            request.getAuditHistory(params).then(res => {
                this.auditHistoryTable = res
            })
        },
        //明细颜色
        tableRowClass ({ row }) {
            if(row.changeType == -1) {
                return 'red'
            }else if(row.changeType == 1) {
                return 'AddCol'
            }else if(row.changeType == 2) {
                return 'yellow'
            }
            // else if(row.children) {
            //     return 'warning-row'

            // }
            return ''
        },
        // 获取最后一个内容区域的高度，计算底部空白
        getLastConHeight () {
            let si = setInterval(() => {
                // 因为dom异步加载，通过轮询找到渲染后的dom，获取高度
                if (document.getElementById('evaluateCon')) {
                    const lastConHeight =
            document.getElementById('evaluateCon').offsetHeight
                    console.log('lastConHeight: ', lastConHeight)
                    this.lastConHeight = lastConHeight
                    console.log('this.lastConHeight', this.lastConHeight)
                    clearInterval(si)
                    si = null
                }
            }, 100)
        },

        cellClick (row) {
            this.dtlId1 = row.dtlId
        },

        handleFullScreen () {
            this.fullscreen = !this.fullscreen
        },

        //取消
        cancel () {
            this.dialogVisible = false
            this.$router.push('./sporadicPurchase')
        },
        cellClsNm ({ column }) {
            if (column.label === '') {
                return 'fixed-left'
            }
        },

        onChangeTab (e) {
            const height  = $('#' + e.name).offset().top
            $.scrollTo(height - this.topHeight, 500)
            // 如果手动点击时，则不做滚动事件逻辑，只有滚动屏幕时才走滚动事件逻辑
            this.clickTabFlag = true
            // 动画结束后，恢复状态
            setTimeout(() => {
                this.clickTabFlag = false
            }, 600)
        },

        //获取当前时间
        geyDate () {
            var myDate = new Date()
            return myDate
        },
    },
}
</script>

<style lang="scss" scoped>
.buttons {
  left: 0;
}
.e-form {
  margin-bottom: 80px;
  padding: 0 20px;
  .tabs-title::before {
    content: "";
    height: 22px;
    width: 8px;
    border-radius: 40px;
    background-color: #2e61d7;
    display: block;
    position: absolute;
    left: 20px;
    margin-right: 20px;
  }
}

.e-table {
  background: #fff;
}
// ::v-deep.el-table__body-wrapper::-webkit-scrollbar{
//      width: 6px !important; // 横向滚动条
//     height: 10px !important// 纵向滚动条
// }

::v-deep .el-table__body-wrapper::-webkit-scrollbar {
  width: 6px; // 横向滚动条
  height: 10px; // 纵向滚动条
}
// 滚动条的滑块
::v-deep .el-table__body-wrapper::-webkit-scrollbar-thumb {
  background-color: #ddd;
  border-radius: 5px;
}

.el-tab-pane {
  margin-left: -10px;
}

</style>